#include<cstdio>
#include<algorithm>
int n,q,op,x,v,a[8003];
struct node{
	int idx;
	int val;
	void outp(){
		printf("(%d,%d)",val,idx);
	}
}b[8002];
bool cmp(node p,node q){
	if(p.val==q.val)return p.idx<q.idx;
	return p.val<q.val;
}
void swap(node &p,node &q){
	node t=p;
	p=q,q=t;
}
int main(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i].val);
		b[i].idx=i;
	}
	std::sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;i++)a[b[i].idx]=i;
	for(int i=1;i<=q;i++){
		scanf("%d%d",&op,&x);
		if(op==2){
			printf("%d\n",a[x]);
			continue;
		}
		scanf("%d",&b[a[x]].val);
		while(a[x]>1&&cmp(b[a[x]],b[a[x]-1])){
			a[x]--;
			a[b[a[x]].idx]++;
			swap(b[a[x]],b[a[x]+1]);
		}
		while(a[x]<n&&cmp(b[a[x]+1],b[a[x]])){
			a[x]++;
			a[b[a[x]].idx]--;
			swap(b[a[x]-1],b[a[x]]);
		}
	}
	return 0;
}
